﻿@model DesignerViewModel

<div>
    <div class="layui-container" style="margin-top:50px;margin-bottom:150px">
        <form class="layui-form" id="frmAdd">
            <div class="layui-form-item">
                <label class="layui-form-label" style="font-weight:bolder;">名称</label>
                <div class="layui-input-block">
                    <input type="text" asp-for="Name" required lay-verify="title" autocomplete="off" class="layui-input">
                    <span asp-validation-for="Name" style="color: #F56C6C"></span>
                    @*<input type="text" id="Title" class="layui-input" placeholder="请输入标题" />*@
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="font-weight:bolder;">路径</label>
                <div class="layui-input-block">
                    <input type="text" asp-for="ImgUrl" required lay-verify="title" autocomplete="off" class="layui-input">
                    <span asp-validation-for="ImgUrl" style="color: #F56C6C"></span>
                    @*<input type="text" id="Title" class="layui-input" placeholder="请输入标题" />*@
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="font-weight:bolder;">职务</label>
                <div class="layui-input-block">
                    <input type="text" asp-for="Position" required lay-verify="title" autocomplete="off" class="layui-input">
                    <span asp-validation-for="Position" style="color: #F56C6C"></span>
                    @*<input type="text" id="ToUrl" class="layui-input" placeholder="请输入跳转地址" />*@
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="*">添加</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
@section Scripts{
    <script>//Demo
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.$;
            //监听提交
            form.on('submit(*)', function (data) {
                $.post("/admin/Designer/Add", data.field, function (re) {
                if (re.success) {
                    //发异步，把数据提交给
                    layer.alert(re.msg, { icon: 6 }, function () {
                        parent.layui.$("#subAdd").click();
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        //刷新父级页面
                        parent.location.reload();
                    });
                } else {
                    layer.msg(re.msg);
                }
            }, "json");
            return false;
            });
            });</script>
}